﻿using System;
using System.Drawing;

public class Image
{
    public Bitmap buffer;
    public int width;
    public int height;
    public float pixelWidth;
    public float pixelHeight;
	public Image(int width, int height, float pWidth, float pHeight)
	{
        this.width = width;
        this.height = height;
        this.pixelWidth = pWidth;
        this.pixelHeight = pHeight;
        buffer = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
	}
    public void setPixel(int x, int y, LightIntensity pixel)
    {
        int red, green, blue;
        red = (int)(255 * (pixel.r > 1.0 ? 1.0 : (pixel.r < 0.0 ? 0.0 : pixel.r)));
        green = (int)(255 * (pixel.g > 1.0 ? 1.0 : (pixel.g < 0.0 ? 0.0 : pixel.g)));
        blue = (int)(255 * (pixel.b > 1.0 ? 1.0 : (pixel.b < 0.0 ? 0.0 : pixel.b)));
        buffer.SetPixel(x,y,Color.FromArgb(red, green, blue));
    }
    public void saveImage(string filename)
    {
        buffer.Save(filename, System.Drawing.Imaging.ImageFormat.Bmp);
    }
}
